package com.woniu.zsd.commons.core.model;

import java.util.List;
import java.util.Set;

public class Results<T> {
        private String msg;
        private T data;
        private Integer code;

        public String getMsg() {
            return msg;
        }

        public Results<T> setMsg(String msg) {
            this.msg = msg;
            return this;
        }

        public T getData() {
            return data;
        }

        public Results<T> setData(T data) {
            this.data = data;
            return this;
        }

        public Integer getCode() {
            return code;
        }

        public Results<T> setCode(Integer code) {
            this.code = code;
            return this;
        }


        // 创建一个指定类型的Result对象，状态码为200，消息为"访问成功"
        public static <S> Results<S> getResult(Class<S> type) {
            Results<S> result = new Results<>();
            result.setCode(200);
            result.setMsg("访问成功");
            return result;
        }

        // 创建一个默认的Result对象，状态码为200，消息为"访问成功"
        public static Results<?> getResult() {
            Results<?> result = new Results<>();
            result.setCode(200);
            result.setMsg("访问成功");
            return result;
        }

        // 创建一个包含List类型数据的Result对象，状态码为200，消息为"访问成功"
        public static <S> Results<List<S>> getListResult(Class<S> type) {
            Results<List<S>> result = new Results<>();
            result.setCode(200);
            result.setMsg("访问成功");
            return result;
        }

        // 创建一个包含Set类型数据的Result对象，状态码为200，消息为"访问成功"
        public static <S> Results<Set<S>> getSetResult(Class<S> type) {
            Results<Set<S>> result = new Results<>();
            result.setCode(200);
            result.setMsg("访问成功");
            return result;
        }
        public String toString() {
            return "Result{" +
                    "msg='" + msg + '\'' +
                    ", data=" + data +
                    ", code=" + code +
                    '}';
        }


}
